import pandas as pd

# 显示所有列
pd.set_option('display.max_columns', 1000)
pd.set_option('display.width', 1000)  # 设置宽度,就是说不换行,比较好看数据
pd.set_option('display.max_rows', 100)  # 设置行数的多少


def run():
    "ffT".lower()
    "".startswith("")
    df = pd.read_excel(
        "C:\\Users\\ljc\\Documents\\WXWork\\1688855722359504\\Cache\\File\\2024-04\\延时周期中断超过30分钟.xlsx",
        sheet_name=None)
    print(list(df.keys()))
    for sheet in list(df.keys()):
        # if 'delay' in sheet:
        df_sheet = df[sheet]
        df_sheet = df_sheet[df_sheet['sn'] == "SNDOUBLETEST01"]

        df_sheet = df_sheet.loc[:, ["sn", "timestamp", "changingdoor",
                                    "colddoor", "freezedoora",
                                    "freezedoorb", "evnsensortempreture",
                                    "coldroomairdoorstatus", "compressorspeed", "compressorstatus",
                                    "freezeroomevaporationsensortempreture", "freezeroomtargettempreture",
                                    "freezeroomsensortempreture", "defrostRequest",
                                    "freezeheat"]]
        df_sheet.fillna('', inplace=True)
        df_sheet['timestamp'] = df_sheet['timestamp'].apply(lambda x: str(x)[0:19])
        # print(df_sheet)
        df_sheet.to_csv(f"C:\\Users\\ljc\\Documents\\WXWork\\1688855722359504\\Cache\\File\\2024-04\\{sheet}.csv",
                        index=False, sep=',')
        print(sheet, ' done ')


if __name__ == '__main__':
    # run()
    key = "hbase-test/p_date=2021-01-01/2024022218-devmsg_aircondition_orignal.log.gz"

    arr = key.split('/')
    a2 = arr[1].split('=')
    p_date = a2[1].replace('-','')
    file_name = arr[2]

    print(p_date)
    print(file_name)
